﻿(function ($) {
    ///序列化标签内所有表单元素的值为一个 JSON 对象。
    $.fn.serializeObject = function () {
        var obj = {};
        var array = $("*", this).serializeArray();
        $.each(array, function () {
            if (obj[this.name]) {
                if (obj[this.name] == undefined || obj[this.name] == null || obj[this.name]=="") {
                    obj[this.name] = this.value;
                }
            } else {
                obj[this.name] = this.value;
            }
        });
        return obj;
    };
    $.fn.serializeAllObject = function () {
        var obj = {};
        var array = $("*", this).serializeArray();
        $.each(array, function () {
            if (obj[this.name]) {
                if (obj[this.name] == undefined || obj[this.name] == null || obj[this.name] == "") {
                    obj[this.name] = this.value;
                }
            } else {
                obj[this.name] = this.value;
            }
        });
        $(':disabled[name]', this).each(function () {
            obj[this.name] = $(this).val();
        });
        return obj;

    };


    $.fn.serializeDisabled = function () {
        var obj = {};
        $(':disabled[name]', this).each(function () {
            obj[this.name] = $(this).val();
        });
        return $.param(obj);
    }
})(jQuery);